package com.wlstock.funi.model;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.wlstock.funi.utils.TimeUtils;

import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * 
 * @author admin
 *
 */
@DatabaseTable(tableName = "tb_operatemodel")
public class OperateModel extends BaseModel{
//  "holdStockName": "",
//  "listTimeInfo": "",
  //"fundName": "波段3号",
  //"fundid": 3,
//  "customerId": "97892",
//  "rn": 1,
//  "StockHoldDetailId": "6797",
  //"StockNo": "002364",
  //"StockName": "中恒电气",
//  "StockHoldID": "3032",
//  "TradeType": 0,
//  "RealProfit": 348194.64,
//  "ProfitRate": 0.3472,
  //"Remark": "清仓",
  //"CreatedTime": "2015-10-20T11:09:23.11",
//  "totalIncome": 7.3001,
  //"TradePrice": 26.29,
//  "TradedDate": "2015-10-20T11:08:11",
//  "TradedDay": "昨天",
//  "TradedHourMinute": "11:8",
//  "HoldStockName": "",
//  "FloatProfitRate": 0,//持股浮动盈亏
//  "IsStopPlate": 0,
//  "ListTimeInfo": ""
	@DatabaseField(columnName = "StockName",canBeNull = false)
	private String StockName; //证券名字
	
	@DatabaseField(columnName = "StockNo",canBeNull = false)
	private String StockNo;   //证券号码
	
	@DatabaseField(columnName = "fundName",canBeNull = false)
	private String fundName;  //操盘手名
	
	@DatabaseField(columnName = "fundid",canBeNull = false)
	private int fundid;    //操盘手id
	
	@DatabaseField(columnName = "Remark",canBeNull = false)
	private String Remark;    //交易类型显示
	
	@DatabaseField(columnName = "TradeType")
	private int TradeType; //交易类型
	
	@DatabaseField(columnName = "TradePrice")
	private float TradePrice; //交易价格
	
	@DatabaseField(columnName = "TradedDate")
	private Date TradedDate; //交易时间
	
	@DatabaseField(columnName = "CreatedTime")
	private Date CreatedTime; //服务器记录创建时间
	
	@DatabaseField(columnName = "upDateTime")
	private Date upDateTime; //从服务器上拉下来的时间
	
	@DatabaseField(columnName = "HoldStockName")
	private String HoldStockName;
	
	@DatabaseField(columnName = "ListTimeInfo")
	private String ListTimeInfo;
	
	@DatabaseField(columnName = "customerId")
	private String customerId;
	
	@DatabaseField(columnName = "rn")
	private int rn;
	
	@DatabaseField(columnName = "StockHoldDetailId", id = true ,canBeNull = false)
	private String StockHoldDetailId;
	
	@DatabaseField(columnName = "StockHoldID")
	private long StockHoldID;
	
	@DatabaseField(columnName = "RealProfit")
	private float RealProfit;
	
	@DatabaseField(columnName = "ProfitRate")
	private float ProfitRate;//本期收益
	
	@DatabaseField(columnName = "totalIncome")
	private float totalIncome;//总收益
	
	@DatabaseField(columnName = "TradedDay")
	private String TradedDay;
	
	@DatabaseField(columnName = "TradedHourMinute")
	private String TradedHourMinute;
	
	@DatabaseField(columnName = "FloatProfitRate")
	private float FloatProfitRate;
	
	@DatabaseField(columnName = "IsStopPlate")
	private int IsStopPlate;
	
	@DatabaseField(columnName = "season")
	private long season;
	
	public int range;
	public int nums;
	public static final int TradeType_SELL = 0;
	public static final int TradeType_BUY  = 1;
	
	public OperateModel(){}

	public String getStockName() {
		return StockName;
	}

	public void setStockName(String stockName) {
		StockName = stockName;
	}

	public String getStockNo() {
		return StockNo;
	}

	public void setStockNo(String stockNo) {
		StockNo = stockNo;
	}

	public String getFundName() {
		return fundName;
	}

	public void setFundName(String fundName) {
		this.fundName = fundName;
	}

	public int getFundid() {
		return fundid;
	}

	public void setFundid(int fundid) {
		this.fundid = fundid;
	}

	public String getRemark() {
		return Remark;
	}

	public void setRemark(String remark) {
		Remark = remark;
	}

	public int getTradeType() {
		return TradeType;
	}

	public void setTradeType(int tradeType) {
		TradeType = tradeType;
	}
	/**
	 * 
	 * @return 操盘手交易价格
	 */
	public float getTradePrice() {
		return TradePrice;
	}

	public void setTradePrice(float tradePrice) {
		TradePrice = tradePrice;
	}

	public Date getTradedDate() {
		return TradedDate;
	}

	public void setTradedDate(Date tradedDate) {
		TradedDate = tradedDate;
	}

	public Date getCreatedTime() {
		return CreatedTime;
	}

	public void setCreatedTime(Date createdTime) {
		CreatedTime = createdTime;
	}

	public Date getUpDateTime() {
		return upDateTime;
	}

	public void setUpDateTime(Date upDateTime) {
		this.upDateTime = upDateTime;
	}

	public String getHoldStockName() {
		return HoldStockName;
	}

	public void setHoldStockName(String holdStockName) {
		HoldStockName = holdStockName;
	}

	public String getListTimeInfo() {
		return ListTimeInfo;
	}

	public void setListTimeInfo(String listTimeInfo) {
		ListTimeInfo = listTimeInfo;
	}

	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	public int getRn() {
		return rn;
	}

	public void setRn(int rn) {
		this.rn = rn;
	}

	public String getStockHoldDetailId() {
		return StockHoldDetailId;
	}

	public void setStockHoldDetailId(String stockHoldDetailId) {
		StockHoldDetailId = stockHoldDetailId;
	}

	public long getStockHoldID() {
		return StockHoldID;
	}

	public void setStockHoldID(long stockHoldID) {
		StockHoldID = stockHoldID;
	}

	public float getRealProfit() {
		return RealProfit;
	}

	public void setRealProfit(float realProfit) {
		RealProfit = realProfit;
	}

	public float getProfitRate() {
		return ProfitRate;
	}

	public void setProfitRate(float profitRate) {
		ProfitRate = profitRate;
	}

	public float getTotalIncome() {
		return totalIncome;
	}

	public void setTotalIncome(float totalIncome) {
		this.totalIncome = totalIncome;
	}

	public String getTradedDay() {
		return TradedDay;
	}

	public void setTradedDay(String tradedDay) {
		TradedDay = tradedDay;
	}

	public String getTradedHourMinute() {
		return TradedHourMinute;
	}

	public void setTradedHourMinute(String tradedHourMinute) {
		TradedHourMinute = tradedHourMinute;
	}

	public float getFloatProfitRate() {
		return FloatProfitRate;
	}

	public void setFloatProfitRate(float floatProfitRate) {
		FloatProfitRate = floatProfitRate;
	}

	public int getIsStopPlate() {
		return IsStopPlate;
	}

	public void setIsStopPlate(int isStopPlate) {
		IsStopPlate = isStopPlate;
	}

	public long getSeason() {
		return season;
	}

	public void setSeason(long season) {
		this.season = season;
	};
	
    public String getKeepDays(int fundId){
    	switch (fundId) {
		case 1:
		case 3:
		case 4:
		case 5:
		case 8:
		case 9:
		case 10:
			return "1至5日";
		case 2:
		case 6:
		case 7:
			return "1个月";
		default:
			return "未知";
		}
    }	
    
    /**
     * 通过fundid比较两个mode是否相同
     */
    @Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
    	OperateModel comMode = (OperateModel) o;
    	if (this.fundid == comMode.fundid) {
			return true;
		}
		return false;
	}

	@Override
	public String toString() {
		return "本期排名:"+range +"本期持仓人数:"+nums+"\n"+
				"交易时间:"+ new SimpleDateFormat("yyyy-MM-dd").format(CreatedTime)+" 已经过去:"+ TimeUtils.dateDiff(CreatedTime,new Date(), TimeUtils.TIME_PERIOD.DAY)+"天\n"+
				"目标持有时间:"+getKeepDays(fundid);
	}
}
